package org.pan.domain.db;

import org.pan.domain.DomainObject;

import javax.persistence.*;
import java.util.Set;

/**
 * 系统菜单
 * Created by fangjinliu on 2015/11/1 0001.
 */
@Entity
public class SystemMenu extends DomainObject {

    private static final long serialVersionUID = 166216982262518493L;

    @Column
    private String menuName;

    @Column
    private String menuIcon;

    @Column
    private String menuUrl;

    @ManyToOne
    @JoinColumn(name = "parent_id", referencedColumnName = "id")
    private SystemMenu parent;

    @Column(name = "parent_id",insertable = false,updatable = false)
    private Long parentId;

    @OneToMany(cascade = CascadeType.REMOVE,mappedBy = "parent")
    private Set<SystemMenu> children;

    @ManyToMany
    @JoinTable(name = "role_menu",
            joinColumns = {@JoinColumn(name = "menu_id",referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")})
    private Set<SystemRole> systemRoleSet;

    public String getMenuName() {
        return menuName;
    }

    public void setMenuName(String menuName) {
        this.menuName = menuName;
    }

    public String getMenuIcon() {
        return menuIcon;
    }

    public void setMenuIcon(String menuIcon) {
        this.menuIcon = menuIcon;
    }

    public String getMenuUrl() {
        return menuUrl;
    }

    public void setMenuUrl(String menuUrl) {
        this.menuUrl = menuUrl;
    }

    public SystemMenu getParent() {
        return parent;
    }

    public void setParent(SystemMenu parent) {
        this.parent = parent;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public Set<SystemMenu> getChildren() {
        return children;
    }

    public void setChildren(Set<SystemMenu> children) {
        this.children = children;
    }

    public Set<SystemRole> getSystemRoleSet() {
        return systemRoleSet;
    }

    public void setSystemRoleSet(Set<SystemRole> hasRoles) {
        this.systemRoleSet = hasRoles;
    }
}
